home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d899.lha / GoodDouble / sources / GoodDouble2.c < prev   
C/C++ Source or Header  |  1993-07-05  |  2KB  |  81 lines

  1. /*
  2.  *        GoodDouble2.c
  3.  *
  4.  * ( '2' stands here both for second version and for the two mouse-buttons )
  5.  *
  6.  *        by Piotr Obminski
  7.  *
  8.  *        July 1993
  9.  *
  10.  *        version 0.3
  11.  */
  12.  
  13. #include <exec/types.h>
  14. #include <intuition/intuition.h>
  15.  
  16. #include "good_double.h"    /* only needed because of #define GDC_REGARGS */
  17.  
  18.  
  19. #define left_button     0L
  20. #define middle_button   1L
  21. #define right_button    2L
  22.  
  23.  
  24. /* ------------------------------------------------------------------
  25.  * Returns TRUE if the time you give it was inside the double-click
  26.  * time distance from the last time it got; and NO OTHER MOUSE BUTTON
  27.  * WAS CLICKED IN BETWEEN. Otherwise return FALSE.
  28.  *
  29.  * This one is smaller, but handles only the LEFT & RIGHT i.e.
  30.  * the usually available mouse-buttons! If it gets 1 as its first
  31.  * argument, it will return FALSE, but NOT RESET THE TIMES (seconds &
  32.  * micros) for the LEFT & RIGHT mouse-buttons.
  33.  * ----------------------------------------------------------------- */
  34.  
  35. #ifdef GDC_REGARGS
  36.     #ifdef _DCC                    /* i.e. DICE */
  37.             __regargs BOOL
  38.         GoodDouble2( LONG button, ULONG secs, ULONG mics )
  39.     #else
  40.             BOOL
  41.         GoodDouble2( register LONG button,
  42.                     register ULONG secs,
  43.                     register ULONG mics )
  44.     #endif
  45. #else
  46.         BOOL
  47.     GoodDouble2( LONG button, ULONG secs, ULONG mics )
  48. #endif
  49. {
  50.     static ULONG OldLSeconds    = 0L;
  51.     static ULONG OldLMicros     = 0L;
  52.     static ULONG OldRSeconds    = 0L;
  53.     static ULONG OldRMicros     = 0L;
  54.  
  55.     register BOOL ret_val = FALSE;
  56.  
  57.     switch ( button ) {
  58.         case left_button:
  59.             if ( DoubleClick( OldLSeconds, OldLMicros, secs, mics ) ) {
  60.                 OldLSeconds = OldLMicros = 0L;
  61.                 ret_val = TRUE;
  62.             } else {
  63.                 OldLSeconds = secs;
  64.                 OldLMicros  = mics;
  65.             }
  66.             OldRSeconds = OldRMicros = 0L;
  67.             break;
  68.         case right_button:
  69.             if ( DoubleClick( OldRSeconds, OldRMicros, secs, mics ) ) {
  70.                 OldRSeconds = OldRMicros = 0L;
  71.                 ret_val = TRUE;
  72.             } else {
  73.                 OldRSeconds = secs;
  74.                 OldRMicros  = mics;
  75.             }
  76.             OldLSeconds = OldLMicros = 0L;
  77.             break;
  78.     }
  79.     return( ret_val );
  80. }
  81.